package edu.ustb.service;

import java.util.List;

import org.apache.ibatis.session.SqlSession;

import com.github.pagehelper.PageHelper;

import edu.ustb.domain.Address;
import edu.ustb.domain.Cart;
import edu.ustb.domain.Goods;
import edu.ustb.mapper.CartMapper;
import edu.ustb.mapper.GoodsMapper;
import edu.ustb.utils.MybatisUtil;

public class CartIndentImpl implements CartIndent {

	@Override
	public List<Cart> cartToIndent(List<String>checkid) {
		
		SqlSession openSession = MybatisUtil.open();
		CartMapper cartMapper = openSession.getMapper(CartMapper.class);
		List <Cart> slist =cartMapper.cartToOrder(checkid);
		MybatisUtil.close();
		return slist;
	}

	@Override
	public List<Goods> goodsInCartIndent(List<String>checkid) {
		SqlSession openSession = MybatisUtil.open();
		CartMapper cartMapper = openSession.getMapper(CartMapper.class);
		List <Goods> glist =cartMapper.goodsInCartToOrder(checkid);
		MybatisUtil.close();
		return glist;
	}

	@Override
	public List<Address> addressToIndent(List<String> checkid) {
		SqlSession openSession = MybatisUtil.open();
		CartMapper cartMapper = openSession.getMapper(CartMapper.class);
		List <Address> alist =cartMapper.addressToOrder(checkid);
		MybatisUtil.close();
		return alist;
	}

	@Override
	public Goods findGoodsById(int goodsId) {
		SqlSession openSession = MybatisUtil.open();
		CartMapper cartMapper = openSession.getMapper(CartMapper.class);
	
		Goods glist = cartMapper.findGoodsById(goodsId);
		MybatisUtil.close();
		return glist;
	}
}
